<?php


namespace app\api\controller;


use app\common\bean\ConfigBean;
use app\common\bean\ListMap;
use app\common\bean\StoreBean;
use app\common\bean\SwiperBean;
use app\common\controller\ApiController;
use app\common\manage\ConfigManage;
use app\common\manage\ContentManage;
use app\common\manage\SwiperManage;
use app\common\utils\ExitJsonUtil;

class System extends ApiController
{
    protected $beforeActionList = [
        'decryptToken' => ['except' => 'getSwiperList,getConfig'],
    ];
    public function getSwiperList(){//获取轮播图
        $swiperBean = new SwiperBean();
        $swiperBean->setData($this->postParams);
        $swiperList = SwiperManage::getInstance()->getApiSwiperList($swiperBean);
        ExitJsonUtil::getInstance()->exitData($swiperList);
    }

    public function getConfig(){//获取系统配置
        $configList = ConfigManage::getInstance()->getAllConfig();
        $data = ConfigManage::getInstance()->modelToInputSelect($configList,ConfigBean::$configKey,ConfigBean::$value);
        $data['contract'] = $this->request->domain().$data['contract'];
        $listMap = new ListMap();
        $listMap->setParameter('configList',$data);
        $listMap->setParameter("uploadImgUrl",$this->request->domain()."/api/User/uploadImg");
        $listMap->setParameter("uploadFile",$this->request->domain()."/api/user/uploadFile");
        $listMap->setParameter("logo",$this->request->domain()."/static/img/official.jpg");
        ExitJsonUtil::getInstance()->exitData($listMap->getData());
    }

    public function service(){//商家服务列表
        $listMap = new ListMap();
        $listMap->setData($this->postParams);
        $listMap->setParameter('uid', $this->userId);
        $service = ContentManage::getInstance()->getService($listMap);
        ExitJsonUtil::getInstance()->exitData($service);
    }
}